#include "PlaneShot_1.h"
#include "Bullet.h"


PlaneShot_1::PlaneShot_1(void)
{
	_currentTime = 0;
}


PlaneShot_1::~PlaneShot_1(void)
{
	
}

void PlaneShot_1::onEnter()
{
	PlaneShotStrategy::onEnter();
}

void PlaneShot_1::onExit()
{
	PlaneShotStrategy::onExit();
}

void PlaneShot_1::shoot(float dt)
{
	if (_currentTime < getWeapon()->getTimeDelay())
	{
		_currentTime += dt;
		return;
	}
	// Get bullets
	Weapon* _weapon = getWeapon();
	if (!_weapon)
		return;
	CCArray* bullets = _weapon->addBullet();
	// Change direct bla bla. In this case,	no need to change
	for (int i = 0; i < bullets->count(); i++)
	{
		Bullet* bullet = dynamic_cast<Bullet*>(bullets->objectAtIndex(i));
		CCPoint bu1Pos = bullet->getPosition();
		CCPoint a = ccp(getOwner()->boundingBox().getMidX(), getOwner()->boundingBox().getMaxY()) + bu1Pos;
		bullet->setPosition(ccp(getOwner()->boundingBox().getMidX(), getOwner()->boundingBox().getMaxY()) + bu1Pos);
	}
	_currentTime = 0;
}


